<template>
  <div>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" label="编号" width="80"></el-table-column>
      <el-table-column prop="name" label="姓名" width="55"></el-table-column>
      <el-table-column prop="phone" label="电话" width="120"></el-table-column>
      <el-table-column prop="email" label="邮箱地址"></el-table-column>
      <el-table-column prop="address" label="地址"></el-table-column>
      <el-table-column prop="createTime" label="创建时间"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="info" @click="handleEdit(scope.row)" icon="el-icon-s-operation">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.row)" icon="el-icon-delete-solid">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      background
      layout="prev, pager, next"
      @current-change="handlerCurrent"
      :current-page="currentPage"
      :page-size="pageSize"
      :total="totals">
    </el-pagination>

  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData:[], //表格数据
      currentPage:1,//当前页页数
      pageSize:5,   //每页显示条数
      totals:0      //数据总条数
    }
  },
  methods:{
    getStudents(){
      this.$http.post("/stu/list",
        {'currentPage':this.currentPage,'pageSize':this.pageSize}).then(res=>{
          this.tableData = res.data.data;
          this.totals = res.data.totals;
      })
    },
    handleEdit(row){
    },
    handleDelete(row){
    },
    handlerCurrent(currentPage){
      //获取当前页
      this.currentPage = currentPage;
      //发送请求重新刷新列表
      this.getStudents();
    },
  },
  mounted() {
    this.getStudents();
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
